<extend name="Common:grid"/>
<!-- 
 ------------------------------------------------------
  管理组页面
 ------------------------------------------------------
 -->
<block name="extOptions">
var subGridOptions=$.extend({},defaultJqGridOptions);
$.extend(defaultJqGridOptions,{
	colModel:[
		{name:"group_id",index:"id",hidden:true,editable:false,search:false},
		{name:"name",index:"name",align:"left",width:300,sortable:false,editable:true,editrules:{required:true},search:false},
		{name:"level",index:"level",align:"center",width:200,sortable:true,editable:true,editoptions:{defaultValue:1},
			editrules:{required:true,integer:true,minValue:1},search:false},
		{name:"action",align:"center",width:100,fixed:true,resize:false,sortable:false,formatter:"actions",
			formatoptions:{
				keys:true,
				editbutton:<if condition="$pager.edit eq 1">true<else/>false</if>,
				delbutton:<if condition="$pager.del eq 1">true<else/>false</if>,
				onSuccess:function(response){
					var json=toJson(response);
					if(json.status==0){
						//gridWarning(json.info,this.p);
						gridWarning(json.info);
						return false;
					}
					return true;
				},delOptions:{
					afterSubmit:process
				}
			},search:false,viewable:false}
	],
	sortname:"level",
	jsonReader:{
		repeatitems:false,
		id:"group_id"
	},
	subGrid:<if condition="$pager.edit eq 1 or $pager.del eq 1">true<else/>false</if>,
	subGridRowExpanded:function(subgrid_id,row_id){
		//管理员子表
		var subgridTable="subgrid_admin_table"+subgrid_id;
		var subgridPager="subgrid_admin_pager"+subgrid_id;
   		$("#"+subgrid_id).html("<table id='"+subgridTable+"'></table><div id='"+subgridPager+"'></div>");
		//子表配置参数
		$.extend(subGridOptions,{
			url:BASE+"/admin/manage/admin?group_id="+row_id,
		    height:80,
		    width:$("#{$layout}_{$Think.ACTION_NAME}_table").width()-100,
		    caption:"{$Think.lang.ADMIN_CAPTION}",
		    colNames:[{$Think.lang.ADMIN_COL_NAMES}],
		    colModel:[
		    	{name:"id",index:"id",hidden:true},
		        {name:"username",index:"username",width:100,align:"left",sortable:false,editable:true,editrules:{required:true}},
		        {name:"name",index:"name",width:100,align:"left",sortable:false,editable:true,editrules:{required:true}},
		        {name:"password",index:"password",hidden:true,align:"left",sortable:false,editable:true,edittype:"password",viewable:false,
					editrules:{edithidden:true},editoptions:{dataInit:function(elem){$(elem).val("");}},search:false},
				{name:"group_id",index:"group_id",hidden:true},
		    ],
		    pager:"#"+subgridPager,
			rowNum:0,
			editurl:BASE+"/admin/manage/admin_oper?group_id="+row_id
		});
		$("#"+subgridTable).jqGrid(subGridOptions);
		var subGridPagerEditOptions=$.extend({},defaultPagerEditOptions);
        $.extend(subGridPagerEditOptions,{recreateForm:true});
	    $("#"+subgridTable).jqGrid("navGrid","#"+subgridPager,defaultPagerVisiableOptions,subGridPagerEditOptions,defaultPagerAddOptions,
			defaultPagerDelOptions,defaultPagerSearchOptions,defaultPagerViewOptions);
	}
});
</block>